<template>
  <div class="mod-api__userbalancelog">
    <el-form :inline="true" :model="state.dataForm" @keyup.enter="state.getDataList()">
      <el-form-item>
        <el-input v-model="state.dataForm.realName" placeholder="真实姓名" clearable></el-input>
      </el-form-item>
      <el-form-item>
        <el-select v-model="state.dataForm.recordType" placeholder="请选交易类型" value-key="" clearable filterable @change="">
          <el-option  key="" label="全部" value=""> </el-option>
          <el-option :key="sd.value" :label="sd.label" :value="sd.value" v-for="sd in jjxcf"> </el-option>
        </el-select>
      </el-form-item>

      <el-form-item>
        <el-select v-model="state.dataForm.isPass" placeholder="请选择审核状态" value-key="" clearable filterable @change="">
          <el-option  key="" label="全部" value=""> </el-option>
          <el-option  key="0" label="未审核" value="0"> </el-option>
          <el-option  key="1" label="待审核" value="1"> </el-option>
          <el-option  key="2" label="审核通过" value="2"> </el-option>
          <el-option  key="3" label="审核不通过" value="3"> </el-option>
        </el-select>
      </el-form-item>

      <el-form-item>
        <el-button  type="primary" @click="state.getDataList()">搜索</el-button>
      </el-form-item>


      <el-form-item>
        <el-button  type="primary" @click="addOrUpdateHandle()">新增</el-button>
      </el-form-item>
      <el-form-item>
        <el-button  type="danger" @click="state.deleteHandle()">删除</el-button>
      </el-form-item>
    </el-form>
    <el-table v-loading="state.dataListLoading" :data="state.dataList" border @selection-change="state.dataListSelectionChangeHandle" style="width: 100%">
      <el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
             
              <el-table-column prop="realName" label="用户姓名" header-align="center" align="center"></el-table-column>
              <el-table-column prop="idCard" label="身份证" header-align="center" align="center"></el-table-column>
              
              <el-table-column prop="balance" label="金额 交易" header-align="center" align="center"></el-table-column>
             <!-- <el-table-column prop="type" label="收入 " header-align="center" align="center"></el-table-column> -->
              <el-table-column prop="recordType" label="交易类型" header-align="center" align="center">
                
                <template #default="scope">
                  {{ jjhhxcdt(scope.row.recordType) }}
                </template>
              </el-table-column>
              <el-table-column prop="recordChannel" label="交易渠道" header-align="center" align="center">
                
                <template #default="scope">
                  {{ jioayiquse(scope.row.recordChannel) }}
                </template>
              </el-table-column>
              <!-- <el-table-column prop="recordTime" label="交易时间" header-align="center" align="center"></el-table-column> -->
              <el-table-column prop="recordImg" label="转账截图" header-align="center" align="center" width="100">
                <template #default="scope">
                  <el-image style="width: 40px; height: 40px" :src="scope.row.recordImg"  v-if="scope.row.recordImg" />
                </template>
              </el-table-column>
              <el-table-column prop="isPass" label="状态" header-align="center" align="center">
                
                <template #default="scope">
                  {{ xkkfdrxe(scope.row.isPass) }}
                </template>
              </el-table-column>
              <el-table-column prop="createTime" label="创建时间" header-align="center" align="center"></el-table-column>
            <el-table-column label="操作" fixed="right" header-align="center" align="center" width="150">
        <template v-slot="scope">
          <el-button  type="primary" link @click="addOrUpdateHandle(scope.row.id)">修改</el-button>
          <el-button  type="primary" link @click="state.deleteHandle(scope.row.id)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination :current-page="state.page" :page-sizes="[10, 20, 50, 100]" :page-size="state.limit" :total="state.total" layout="total, sizes, prev, pager, next, jumper" @size-change="state.pageSizeChangeHandle" @current-change="state.pageCurrentChangeHandle"> </el-pagination>
    <!-- 弹窗, 新增 / 修改 -->
    <add-or-update ref="addOrUpdateRef" @refreshDataList="state.getDataList">确定</add-or-update>
  </div>
</template>

<script lang="ts" setup>
import useView from "@/hooks/useView";
import { reactive, ref, toRefs } from "vue";
import AddOrUpdate from "./detailEarnings-add-or-update.vue";
import {jioayiquse,xkkfdrxe,zkjsd} from "@/utils/utils"
const jjxcf =ref([])
const view = reactive({
  deleteIsBatch: true,
  getDataListURL: "/api/userbalancelog/page??type=1",
  getDataListIsPage: true,
  exportURL: "/api/userbalancelog/export",
  deleteURL: "/api/userbalancelog"
});

const state = reactive({ ...useView(view), ...toRefs(view) });

const addOrUpdateRef = ref();
const addOrUpdateHandle = (id?: number) => {
  addOrUpdateRef.value.init(id);
};
const getsd = async () => {
  jjxcf.value = []
  const { list } = await zkjsd("1766439687764508673")
  list.map(a => {
    jjxcf.value.push({
      label: a.dictLabel,
      value: a.dictValue
    })
  })
}
getsd()
const jjhhxcdt = (data)=>{
  try{
  return jjxcf.value.filter(a=>a.value==data)[0].label
 }catch(e){
  return '-'
 }
}
</script>
